﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OnlyMusic.DomainModel.Repositories;
using OnlyMusic.DomainModel.Entities;

namespace OnlyMusic.Persistence
{
    public class SongRepository : ISongRepository
    {
        private OnlyMusicDbContext db = null;

        public SongRepository(OnlyMusicDbContext db)
        {
            if (db == null)
                db = new OnlyMusicDbContext();
            this.db = db;
        }

        public IEnumerable<Song> GetAll()
        {
            return this.db.Set<Song>().AsEnumerable();
        }

        public DomainModel.Entities.Song Get(EnterApp.Core.DomainModel.UniqueId id)
        {
            return this.db.Set<Song>().Find(id);
        }

        public void Add(Song song)
        {
            this.db.Add(song);
        }
    }
}
